package com.skyz.wrap.dialog;

import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.view.KeyEvent;
import android.view.View;
import android.widget.TextView;

import com.allenliu.versionchecklib.v2.builder.UIData;
import com.skyz.wrap.R;

public class AppUpdateDialog extends Dialog {

    public AppUpdateDialog(Context context) {
        super(context,R.style.dialog_pay_theme);
        setContentView(R.layout.dialog_app_update);
        onLayoutInflated();
    }


    private TextView tv_title, tv_description;
    private View app_update_close,app_update_btn;
    protected void onLayoutInflated() {

        tv_description = findViewById(R.id.tv_description);
        tv_title = findViewById(R.id.tv_title);
        app_update_close = findViewById(R.id.versionchecklib_version_dialog_cancel);
        app_update_btn = findViewById(R.id.versionchecklib_version_dialog_commit);

//        app_update_btn.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                dismiss();
//            }
//        });
//        app_update_close.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                dismiss();
//            }
//        });
        setCanceledOnTouchOutside(false);
        setCancelable(false);
        setOnKeyListener(new OnKeyListener() {
            @Override
            public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
                if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) {
                    return true;
                }
                return false;
            }
        });
    }

    public void setUiData(UIData versionBundle,boolean isForece) {
        if (isForece){
            app_update_close.setVisibility(View.GONE);
        }
        tv_title.setText(versionBundle.getTitle());
        tv_description.setText(versionBundle.getContent());
    }
}
